Skip to content

Cut text at the available width instead of a character count - #306

Merged
stippi merged 2 commits into
mainfrom
fix/text-truncation
Nov 5, 2026
Merged

stippi merged 2 commits into
mainfrom
fix/text-truncation

Conversation

@stippi

@stippi stippi commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Text in the GPUI frontend is now cut at the width a row has, with a typographic ellipsis, instead of at a fixed number of characters. The limits came from an old gpui race in its truncation cache, which is fixed in the version we use.

The notification for a finished background job stuck out on the right, and the collapsed plan cut its active item at 60 characters although there was room. Both are fixed.

What changed

  • Fixed lengths removed: plan, terminal cards, read_files / search_files, inline tools, the sub-agent line, the comment chip and browser tabs. Tabs now have a maximum width of 220 px.
  • Two lines: commands in terminal cards and retry messages clamp to two lines. The permission summary and the PR draft text now end in an ellipsis too.
  • One way to do it: one-line rows use .truncate(), and shared::text::single_line turns text with line breaks into one line. AGENTS.md notes the rule.
  • Other overflows: a read through the crate found more rows that could not shrink, for example in the PR header, pickers, slash menu and settings. Error messages there now wrap instead of being cut.

Bugs fixed along the way

  • read_files, search_files and inline tool descriptions sliced at a byte offset and could panic inside a multi-byte character.
  • render_icon_container could shrink in tight rows.

Behaviour to look at

  • The sub-agent line now reads Sub-agent finished · task, so the state survives the cut.
  • A failed tool's description and error message are cut separately, so a long description doesn't push the error out.
  • single_line and the terminal commands still limit text to 1024 characters. That is more than a window shows and only keeps huge tool parameters from being shaped in full on every layout.

Verification

  • cargo test -p ui_gpui --lib and clippy on ui_gpui pass; other crates were not run locally. New layout tests cover the long notification and the collapsed plan.
  • Checked by screenshot in an isolated app instance with a seeded session, in one fixed window size. Narrow windows are only covered by those tests, for the notification.

Not changed: the worktree selector, the repo picker button in the PR list and the tag pill in tool headers. The first two were uncertain findings; the pill only overflows when it alone is wider than the row.

🤖 Generated with Claude Code

Tool lines, the collapsed plan, notifications, chips and card headers cut
their text with gpui's own truncation now. The character limits came from
a gpui race that is long fixed; two of them sliced at byte offsets and
panicked inside multi-byte characters.

Flex items that showed dynamic text got a way to shrink, so they no longer
stick out of their row. A long sub-agent line or failed tool keeps its
state and error message in view.
@stippi
stippi merged commit 55ff7b6 into main Nov 5, 2026
6 checks passed
@stippi
stippi deleted the fix/text-truncation branch November 5, 2026 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant